/*
 * ECARX Technology Limited is the owner of the copyright and the trade secret of this software.
 * Without permission, no one has the right to obtain, disclose or use this software in any way.
 */

package com.ecarx.systemui.plugin;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

import com.ecarx.systemui.plugin.controller.BluetoothController;
import com.ecarx.systemui.plugin.controller.CarVoiceController;
import com.ecarx.systemui.plugin.ui.statusbar.StatusBarView;
import com.ecarx.systemui.plugin.utils.LogUtils;
import com.ecarx.systemui.plugin.utils.ThreadUtils;


public class StatusBar {

    private static final String TAG = "StatusBarTag";

    private static StatusBar statusBar;
    private View mRootView;

    private StatusBar(Context context) {
        threadInit(context);
        startLoad(context);
    }

    private void threadInit(Context context) {
        ThreadUtils.start(new Runnable() {
            @Override
            public void run() {
                PluginContext.initSavePluginContext(context);
                BluetoothController.initBluetooth();
                CarVoiceController.initCar();
            }
        });
    }

    public static synchronized StatusBar init(Context context) {
        if (statusBar == null) {
            statusBar = new StatusBar(context);
        }
        return statusBar;
    }


    @SuppressLint("InflateParams")
    private void startLoad(Context context) {
//        mRootView = LayoutInflater.from(context).inflate(R.layout.status_bar_view, null, false);
        mRootView = new StatusBarView(context);
    }


    public View getRootView() {
        mRootView.requestLayout();
        return mRootView;
    }

}
